# -*- coding:utf-8 -*-


from common.import_pyside import *
from common.data import DB


class RecordStepWindow(QDialog):

    def __init__(self, parent=None):
        super(RecordStepWindow, self).__init__(parent=parent)
        # self.mouse_start_pt = None
        # self.window_pos = None
        # self.drag = None
        self.resize(200, 80)
        self.move(1700, 500)
        self.setStyleSheet("background-color: rgba(173, 155, 120, 0.7);border-radius:5px;")
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        layout = QVBoxLayout()
        layout.addWidget(QLabel("2323"))

        self.setLayout(layout)

    def enterEvent(self, event):
        # self.setWindowFlags(Qt.WindowType.WindowTitleHint)
        print("enter")

    def leaveEvent(self, event):
        # self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint)
        print("leaveEvent")

    # Pyside6 的移动
    # def mousePressEvent(self, event: QMouseEvent) -> None:
    #     if event.button() == Qt.LeftButton:
    #         self.mouse_start_pt = event.globalPosition().toPoint()
    #         self.window_pos = self.frameGeometry().topLeft()
    #         self.drag = True
    #
    # def mouseMoveEvent(self, event: QMouseEvent) -> None:
    #     if self.drag:
    #         distance = event.globalPosition().toPoint() - self.mouse_start_pt
    #         self.move(self.window_pos + distance)
    #
    # def mouseReleaseEvent(self, event: QMouseEvent) -> None:
    #     if event.button() == Qt.LeftButton:
    #         self.drag = False

    def mousePressEvent(self, event):  ##事件开始
        if event.button() == Qt.LeftButton:
            self.Move = True  ##设定bool为True
            self.Point = event.globalPos() - self.pos()  ##记录起始点坐标
            event.accept()

    def mouseMoveEvent(self, QMouseEvent):  ##移动时间
        if Qt.LeftButton and self.Move:  ##切记这里的条件不能写死，只要判断move和鼠标执行即可！
            self.move(QMouseEvent.globalPos() - self.Point)  ##移动到鼠标到达的坐标点！
            QMouseEvent.accept()

    def mouseReleaseEvent(self, QMouseEvent):  ##结束事件
        self.Move = False


if __name__ == '__main__':
    app = QApplication()
    win = RecordStepWindow()
    win.show()
    app.exec()
